package Man.glass.bean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import Man.glass.entity.glass;
import Man.glass.mgr.AppManagerMgr;

@ManagedBean(name="appIndexBean")
@SessionScoped
public class AppIndexBean {
	
	private List<glass> glassList =new ArrayList<glass>();
	
	AppManagerMgr AMM =new AppManagerMgr();
	
	private glass selectGlass;
	
	private String inputName;
	private String inputModel;
	private String inputUserCrowd;
	private String inputCategory;
	
	public AppIndexBean(){
		selectGlass =new glass();
		inputName="";
		inputModel="";
		inputUserCrowd="";
		inputCategory="";
		this.queryData();
	}
	
	public void initPage(){
		selectGlass =new glass();
		inputName="";
		inputModel="";
		inputUserCrowd="";
		inputCategory="";
		this.queryData();
	}
	
	public void queryData(){
		Map<String, String> condition =new HashMap<String, String>();
		if(inputName!=""){
			condition.put("Name", inputName);
		}
		if(inputModel!=""){
			condition.put("Model", inputModel);
		}
		if(inputUserCrowd!=""){
			condition.put("UserCrowd", inputUserCrowd);
		}
		if(inputCategory!=""){
			condition.put("Category", inputCategory);
		}
		glassList=AMM.queryGlass(condition);
	}
	
	public String goToIndex(){
		initPage();
		return"/page/index";
	}

	public String getInputName() {
		return inputName;
	}

	public void setInputName(String inputName) {
		this.inputName = inputName;
	}

	public String getInputModel() {
		return inputModel;
	}

	public void setInputModel(String inputModel) {
		this.inputModel = inputModel;
	}

	public String getInputUserCrowd() {
		return inputUserCrowd;
	}

	public void setInputUserCrowd(String inputUserCrowd) {
		this.inputUserCrowd = inputUserCrowd;
	}

	public String getInputCategory() {
		return inputCategory;
	}

	public void setInputCategory(String inputCategory) {
		this.inputCategory = inputCategory;
	}

	public List<glass> getGlassList() {
		return glassList;
	}

	public void setGlassList(List<glass> glassList) {
		this.glassList = glassList;
	}

	public glass getSelectGlass() {
		return selectGlass;
	}

	public void setSelectGlass(glass selectGlass) {
		this.selectGlass = selectGlass;
	}
	
}
